#include <iostream>
#include <algorithm>
#include <cstring>
using namespace std;
const int MAXN(1e5+8);
int T,n,m,L,V,cnt,ans;
int d[MAXN],v[MAXN],a[MAXN],p[MAXN];
int l[MAXN],r[MAXN];
bool detectors[10*MAXN];
bool check(){
    for(int i=1;i<=n;i++){
        bool have(false);
        for(int j=l[i];j<=r[i];j++){
            if(detectors[j]){
                have=true;
                break;
            }
        }
        if(!have){
            return false;
        }
    }
    return true;
}
void dfs(int dep){
    if(dep==m+1){
        int sum=0;
        for(int i=1;i<=m;i++){
            if(!detectors[p[i]]&&check()){
                sum++;
            }
        }
        ans=max(ans,sum);
        return;
    }else{
        detectors[p[dep]]=false;
        dfs(dep+1);
        detectors[p[dep]]=true;
        dfs(dep+1);
    }
}
int main(){
    cin.tie(NULL);
    cout.tie(NULL);
    ios::sync_with_stdio(false);
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    cin>>T;
    while(T--){
        ans=0;
        bool cheat(true);
        cnt=0;
        memset(detectors,false,sizeof(detectors));
        cin>>n>>m>>L>>V;
        for(int i=1;i<=n;i++){
            cin>>d[i]>>v[i]>>a[i];
        }
        for(int i=1;i<=m;i++){
            cin>>p[i];
            detectors[p[i]]=true;
        }
        for(int i=1;i<=n;i++){
            if(d[i]>p[m]){
                continue;
            }
            if(a[i]==0){
                if(v[i]>V){
                    cnt++;
                    for(int j=d[i];j<=L;j++){
                        if(detectors[j]){
                            l[i]=j;
                            r[i]=p[m];
                            break;
                        }
                    }
                }
            }else if(a[i]>0){
                if(v[i]>V){
                    cnt++;
                    for(int j=d[i];j<=L;j++){
                        if(detectors[j]){
                            l[i]=j;
                            r[i]=p[m];
                            break;
                        }
                    }
                    continue;
                }
                int x=(V*V-v[i]*v[i])/(2*a[i]);
                int fd=d[i]+x+1;
                if(fd<=p[m]){
                    cnt++;
                    for(int j=fd;j<=L;j++){
                        if(detectors[j]){
                            l[i]=j;
                            r[i]=p[m];
                            break;
                        }
                    }
                }
            }else if(a[i]<0){
                cheat=false;
                if(v[i]<=V){
                    continue;
                }
                int x=(v[i]*v[i]-V*V)/(-2*a[i]);
                int fd=d[i]+x;
                if((v[i]*v[i]-V*V)%(-2*a[i])==0){
                    fd--;
                }
                for(int j=fd;j>=d[i];j--){
                    if(detectors[j]){
                        cnt++;
                        r[i]=j;
                        break;
                    }
                }
                for(int j=d[i];j<=fd;j++){
                    if(detectors[j]){
                        l[i]=j;
                        break;
                    }
                }
            }
        }
        cout<<cnt<<' ';
        if(cheat){
            if(cnt!=0){
                cout<<m-1<<"\n";
            }else{
                cout<<m<<"\n";
            }
        }else{
            dfs(1);
            cout<<ans<<"\n";
        }
    }
    return 0;
}
